package cn.edu.just.firstjavaapp.l12;

public class StringBuilderDemo {
    public static void main(String[] args) {
        String sb2 = "abc";
        String name = "张三";
        int age = 20;
        String address="孟溪路2号";
        String longStringh = "我的名字是:"+name+"我的年龄是:"+age+"."+"我住在"+address;
        StringBuilder sb = new StringBuilder();
        sb.append("我的名字是:");
        sb.append(name);
        sb.append("我的年龄是:").append(age).append(".");
        sb.append("我住在").append(address);
        System.out.println(sb);
        System.out.println(sb.length());
        System.out.println("capacity:"+sb.capacity());
        System.out.println(longStringh);
        //
        String[] interests={"游泳","旅游","英语","打羽毛球"};
        //用append拼出一句话:我的兴趣是游泳,旅游,英语,打羽毛球。
        StringBuilder sb3= new StringBuilder();
        sb3.append("我的兴趣是");
        for(String s:interests){
            sb3.append(s).append(",");
        }
        sb3.deleteCharAt(sb3.length()-1);
        sb3.append("。");
        System.out.println(sb3);
    }
}
